﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace AddGenericConstraint.Test
{
    public static class DelegateHelper
    {
        public static Type[] GetDelegateParameters<[AddGenericConstraint(typeof(Delegate))] T>()
        {
            Type type = typeof(T);
            MethodInfo invokeMethod = type.GetMethod( "Invoke" );
            ParameterInfo[] parameters = invokeMethod.GetParameters();
            Type[] parameterTypes = new Type[parameters.Length];
            for ( int i = 0; i < parameterTypes.Length; i++)
            {
                parameterTypes[i] = parameters[i].ParameterType;
            }

            return parameterTypes;
        }
    }
}
